package com.hdu.point_offer;

public class lcr123 {


    public class ListNode {
        int val;
        ListNode next;

        ListNode() {
        }

        ListNode(int val) {
            this.val = val;
        }

        ListNode(int val, ListNode next) {
            this.val = val;
            this.next = next;
        }
    }

    class Solution {
        public int[] reverseBookList(ListNode head) {
            ListNode cur = head;
            int len = 0;
            while (cur != null) {
                len++;
                cur = cur.next;
            }
            int[] ans = new int[len];
            int index = len - 1;
            while (head != null) {
                ans[index--] = head.val;
                head = head.next;
            }
            return ans;
        }
    }

}
